package com.ruoyi.business.service.impl;

import java.util.List;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.ruoyi.business.request.TaskPointReq;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TaskPointMapper;
import com.ruoyi.business.domain.TaskPoint;
import com.ruoyi.business.service.ITaskPointService;

/**
 * 任务点位Service业务层处理
 * 
 * @author Eric
 * @date 2024-03-17
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class TaskPointServiceImpl extends ServiceImpl<TaskPointMapper, TaskPoint> implements ITaskPointService {

    @Override
    public List<TaskPointReq> getTaskPointList(Long taskId) {
        List<TaskPoint> list = this.list(Wrappers.lambdaQuery(TaskPoint.class)
                .eq(TaskPoint::getTaskId, taskId));
        List<TaskPointReq> resultList = Lists.newArrayListWithCapacity(list.size());
        if (CollUtil.isNotEmpty(list)) {
            for (TaskPoint taskPoint : list) {
                TaskPointReq req = new TaskPointReq();
                req.setId(taskPoint.getId());
                req.setId(taskPoint.getId());
                req.setPointName(taskPoint.getPointName());
                req.setLongitude(taskPoint.getLongitude());
                req.setLatitude(taskPoint.getLatitude());
                resultList.add(req);
            }
        }
        return resultList;
    }
}
